// src/router/index.ts
import { createRouter, createWebHistory, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import useRouterHelp from '@/hooks/useRouterHelp';
import { routeGuard } from './route-guard';
import { constRoutes } from './const-route';

const  { generateNestedRoutes } = useRouterHelp();

const loadRoutes = generateNestedRoutes();

const routes = constRoutes.concat(loadRoutes);

// 创建路由实例
const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: routes,
  // 是否应该禁止尾部斜杠。默认为假
  strict: true,
  scrollBehavior: () => ({ left: 0, top: 0 }),
});
// 路由守卫
routeGuard(router);

export default router;